//
//  WZTabBar.m
//  weibo
//
//  Created by mac on 16/2/25.
//  Copyright © 2016年 mac. All rights reserved.
//

#import "WZTabBar.h"


@interface WZTabBar ()

@end


@implementation WZTabBar

-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];

    
    return self;
}

-(UIButton *)btn{
    
    
    if (_btn == nil) {
    
    UIButton *btn = [[UIButton alloc]init];
    
    [btn setImage:[UIImage imageNamed:@"tabbar_compose_icon_add"] forState:UIControlStateNormal];
    [btn setImage:[UIImage imageNamed:@"tabbar_compose_icon_add_highlighted"] forState:UIControlStateSelected];
        
    [btn setBackgroundImage:[UIImage imageNamed:@"tabbar_compose_button"] forState:UIControlStateNormal];
    [btn setBackgroundImage:[UIImage imageNamed:@"tabbar_compose_button_highlighted"] forState:UIControlStateSelected];
        
        _btn = btn;
        [self addSubview:btn];
    }
    return _btn;
}

-(void)layoutSubviews{
    
    [super layoutSubviews];
    
    int index = 0;
    
    CGFloat width = [UIScreen mainScreen].bounds.size.width/5;
    CGFloat height = self.bounds.size.height;
    
    for (UIView *subView in self.subviews) {
        
        
    if ([subView isKindOfClass:NSClassFromString(@"UITabBarButton")]) {
        subView.frame = CGRectMake((index++)*width, 0, width, height);
        }
        if (index == 2) {
            index ++;
        }
        
    
    }
    
    self.btn.frame = CGRectMake(2*width, 0, width, height);
    
   
}

@end
